package work.base.data.collection;

import work.entity.User;

import java.util.ArrayList;
import java.util.List;

/**
 *  java.util.Collection的使用
 *  jdk8 removeIf可以对继承了Collection的集合进行删除操作
 */
public class CollectionTest {

    public static void main(String[] args) {

        User user1 = new User("aa","shen11","123");
        User user2 = new User("bb","shen22","123");
        User user3 = new User("cc","shen33","123");

        List<User> userList = new ArrayList<>();
        userList.add(user1);
        userList.add(user2);
        userList.add(user3);

        // 删除符合条件的元素
        userList.removeIf(a-> a.getName().contains("2"));

        System.out.println(userList);

    }
}
